home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / Plot1D.m < prev    next >
Encoding:
Text File  |  1992-04-25  |  3.0 KB  |  119 lines

  1. /* Plot1D.m    By Paul Kunz    March 1992
  2.  * Replacement of obsolete class used for backward compatiblity.
  3.  *
  4.  * Copyright (C)  1991  The Board of Trustees of  
  5.  * The Leland Stanford Junior University.  All Rights Reserved.
  6.  */
  7.  
  8. #import "Plot1D.h"
  9.  
  10. const char Plot1D_h_rcsid[] = PLOT1D_H_ID;
  11. const char Plot1D_m_rcsid[] = "$Id: Plot1D.m,v 1.64 1992/04/25 00:31:22 pfkeb Rel $";
  12.  
  13. #import <objc/List.h>
  14. #import <objc/Storage.h>
  15. #import <appkit/nextstd.h>
  16.  
  17. #define DEF_PLOT_SIZE 260.0
  18.  
  19. @implementation Plot1D
  20.  
  21. - init
  22. {
  23.     [super init ];
  24.     bounds.origin.x = 0.0;
  25.     bounds.origin.y = 0.0;
  26.     bounds.size.width = DEF_PLOT_SIZE;
  27.     bounds.size.height = DEF_PLOT_SIZE;
  28.     return self;
  29. }
  30. - replaceWithImage
  31. {
  32.     id            plot, plot2;
  33.     cutStorElem        cut;
  34.     int            i, count;
  35.     
  36.     plot = [[Plot allocFromZone:[self zone]] init];
  37.     [plot setBounds:&bounds];
  38.     [plot setHTuple:nil withDisplay:disp];
  39.     [plot setRefFlag:refFlag];
  40.     [plot setFixBinsFlag:fixBinsFlag];
  41.     [plot setRefFilename:reffilename];
  42.     [plot setCutHistFlag:cutHistFlag];
  43.     if ( cutHistFlag ) {
  44.         [plot setCutParms:&cutParms];
  45.     }
  46.     count = [cutPlotStor count];
  47.     for ( i = 0; i < count; i ++ ) {
  48.         cut.plot = [ cutPlotStor elementAt:i];
  49.     [plot addCutPlot: cut.plot];
  50.     }
  51.     count = [dependList count];
  52.     for ( i = 0; i < count; i ++ ) {
  53.         plot2 = [dependList objectAt:i];
  54.     [plot addCutDepend:plot2];
  55.     }
  56.     disp = NULL;
  57.     [self free];
  58.     return plot;
  59. }
  60.   
  61. - read:(NXTypedStream *) ts
  62. {
  63.     id            plot;
  64.     cutStorElem        cut;
  65.     ntuple        *ntlist;
  66.     display        *dlist;
  67.     char        *data;
  68.     int            len, lenref;
  69.     int            i, count;
  70.     
  71.     [super read:ts];
  72.     NXReadTypes( ts, "ccii",    &refFlag, &fixBinsFlag, &len, &lenref);
  73.     NX_ZONEMALLOC( [self zone], data, char, len );
  74.     NX_ZONEMALLOC( [self zone], reffilename, char, lenref+1 );
  75.     NXReadType(  ts, "*",       &reffilename);
  76.     NXReadArray( ts, "c",       len, data );
  77.     h_readMem( data, len,  &dlist, &ntlist );
  78.     NXZoneFree( [self zone], data );
  79.     disp = dlist[0];
  80.     disp->ntuple = NULL;
  81.     NXReadType(  ts, "c",      &cutHistFlag );
  82.     if ( cutHistFlag ) {
  83.         NXReadType( ts, "i",       &len );
  84.     NX_ZONEMALLOC( [self zone], cutParms.cutFunc, char, len+1 );
  85.     NXReadType( ts, "{*iffi}", &cutParms ); 
  86.     NXReadType( ts, "i",       &cutNumber);
  87.     }
  88.     NXReadType(  ts, "i",       &count );
  89.     if ( count ) {
  90.         cutPlotStor = [[Storage allocFromZone:[self zone]] initCount:0
  91.                              elementSize:sizeof(cutStorElem)
  92.                          description:"@*"];
  93.     }
  94.     for ( i = 0; i < count; i++ ) {
  95.         cut.plot = NXReadObject( ts );
  96.     if ( cut.plot ) {
  97.         [cutPlotStor addElement:&cut.plot];
  98.     }
  99.     }
  100.     NXReadType( ts, "i", &count );
  101.     if ( count ) {
  102.         dependList = [[List allocFromZone:[self zone]] initCount:0];
  103.     }
  104.     for ( i = 0; i < count; i++ ) {
  105.         plot = NXReadObject( ts );
  106.     if ( plot ) {
  107.         [dependList addObject:plot];
  108.     }
  109.     }
  110.     return self;
  111. }
  112. - free
  113. {
  114.     NXZoneFree([self zone], reffilename );
  115.     NXZoneFree([self zone], cutParms.cutFunc );
  116.     return [super free];
  117. }
  118. @end
  119.